{extend name="public/base" /}
{block name="style"}
<link rel="stylesheet" href="__PUBLIC__/admin/material/css/index.css?v=20221110&times=111" />
<link rel="stylesheet" href="__PUBLIC__/admin/material/css/iconfont.css" />
{include file="material/_ali_icon" /}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/webuploader/webuploader.css">
<style>
.main-box-body .navs .active {
    background: azure;
    color: #03a9f4;
    border: 1px solid #03a9f4;
    border-radius: 5px;
}
a {
    color: #777;
	text-decoration:none;
}
a:hover { text-decoration :none}
.table tbody>tr>td {padding: 3px 8px;}
.table-hover>tbody>tr:nth-child(odd){background-color: #f9f9f9;}
.table-responsive {
    min-height: 470px;
}

</style>
<style>
	.uploadify-button-text{
		position: relative;
		display: inline-block;
		cursor: pointer;
		background: #fff;
		padding: 0px 5px;
		color: #333;
		text-align: center;
		border-radius: 3px;
		overflow: hidden;
		border: 1px solid #ccc;
	}
	em{
		color: red;
	}
	</style>
{/block}
{block name="body"}
<div class="main-box clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-right">
			{if checkAuthRule('del')}<button type="button" id="checkALL" class="btn btn-warning"> <input class="checkbox check-all" type="checkbox" style="display: inline-block;margin-top: -2px;vertical-align: middle;"> 全选 </button>{/if}
			<!-- <button type="button" class="btn btn-warning"> <input class="checkbox check-all" type="checkbox" style="display: inline-block;margin-top: -2px;vertical-align: middle;"> 全选 </button> -->
			
			{if checkAuthRule('down_all')}<button type="button" class="btn btn-info"  onclick="down_all('{:url('down_all',['source' => 'index'])}')">
				<i class="fa fa-cloud-download"></i> 全库TXT 
			</button>{/if}

			{if !stristr($action, 'hot')}
			<button type="button" class="btn btn-primary" id="createUrl">
				<i class="fa fa-plus"></i> 添加素材 <span class="caret"></span>
			</button>
			{/if}
			<button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>
		</div>
		<div class="row">
			<form method="get">
				
				{include file="material/_search2" /}
			</form>
		</div>
	</header>
	<div class="main-box-body clearfix">

		<!-- 搜索相关 -->
		{include file="material/_search" /}
		
		{include file="material/_search_hot" /}

		<div id="" class="clear"></div>
		<div class="table-responsive clearfix">
			<div class="table-responsive clearfix">
				<table class="table table-hover table-bordered">
					<thead>
						<tr>
							<th width="3%">编号</th>
							<th width="45%"><!--广告文案-->{$menu_name}</th>
							<th width="8%">复制文案</th>
							<th width="5%">工作台</th>
							{include file="material/_score_sort" /}
							<th width="15%">热度/量级/频道/分类/工号</th>
							<th width="5%">标签</th>
							<th width="5%">书名</th>
							<th width="10%">操作</th>
						</tr>
					</thead>
					<tbody>
						{empty name="list"}
						<tr><td colspan="9" align="center">暂无数据</td></tr>
						{/empty}
						{volist name="list" id="vo"}
						<tr>
							<td>
								<!-- <input class="ids row-selected" type="checkbox" name="id[]" value="{$vo['id']}"> -->
								{$vo.id}
							</td>
							<td class="toolTip">
								
								<div class="example" style='font-size: 17px;  color: #5c5c5c;' title2="{$vo.content}">
									<input class="ids row-selected" type="checkbox" name="id[]" value="{$vo['id']}"> &nbsp; {$vo.content_zh}
								</div>
							</td>
							<td>
								<div onclick="copyContent(`{$vo.content}`, {$vo['id']})" class="copy">
									<span class="iconfont icon-copy"></span>
									复制(<span class="copyNum">{$vo['copy_click_num']}</span>) 
								</div>
							</td>
							<td>
								<div onclick="follow(this, {$vo['id']})" class="copy">
									{if $vo['is_follow']}
									&nbsp;已加入
									{else/}
									<span class="fa fa-plus"></span>
									&nbsp;加入
									{/if}
									({$vo['follow_num']}) 
								</div>
							</td>
							<td>{$vo.score}</td>
							<td>{$vo.hot_zh} / {$vo.magnitude_num_zh} / {$vo.channel_zh} / {$vo.category_id_zh} / {$userlist[$vo['uid']]??$vo['uid']} </td>
							<td>{$vo.tag_ids_zh}</td>
							
							<td>{$vo.book_id_zh}</td>
							<td>
								<a href="{:url('del',array('id'=>$vo['id']))}" class="ajax-get confirm"><i class="fa fa-times"></i> 删除</a>
								<a href="JavaScript:;" onclick="editreferral(this)" data-json='{:json_encode($vo)}'><i class="fa fa-edit"></i> 修改</a>
							</td>
						</tr>
						{/volist}
						
					</tbody>
				</table>
			</div>
			{$page}
		</div>
	</div>
</div>

<div class="modal fade" id="create-referral-link-modal">
	<div class="modal-dialog" role="document">
	   <div class="modal-content">
		   <div class="modal-header">
			   <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
			   <span style="font-size: 20px;"><span id="referralname">添加</span></span>
		   </div>
		   <div class="modal-body">
			   <div data-bind="visible: loading" class="loading-panel" style="display: none;">
				   <i class="fa fa-spin fa-spinner"></i>
			   </div>
			   <form class="form-horizontal modelform">
				
				   {include file="material/_from" /}
			   </form>
		   </div>
		   <div class="modal-footer">
			   <button type="button" id="createreferral" class="btn btn-primary ">提交</button>
		   </div>
	   </div>
   </div>
</div>

{include file="adsmaterialbook/_from" /}
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/plugs/layer/layer.js"></script>
<!-- <script src="__PUBLIC__/plugs/moment/moment.min.js"></script>
<script src="__PUBLIC__/plugs/moment/zh-cn.js"></script> -->
<script type="text/javascript" src="__PUBLIC__/plugs/layer/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugs/webuploader/webuploader.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugs/webuploader/webuploader.custom.js"></script>

<script type="text/javascript">

$(function() {
	$('#createUrl').on('click',function(){
		var is_rule = '{:checkAuthRule("add")}';
		if(!is_rule){
			layer.msg("你没权限添加");
			return;
		}
		var $modal = $('#create-referral-link-modal');
		$modal.on('shown.bs.modal', function () {
			//默认选择外
			multipleInput('{:stristr($action, "inside")?3:4}'.split(','),$("input:checkbox[name=hot]"));
			$('#picker_ebook').html('<div>上传文案</div>')
			$("#picker_ebook").SentUploader({
				server:"{:url('Upload/Uploadtxt')}",
				fileNumLimit:1,
				uploadEvents: {
					uploadComplete:function(file){}
				},
				listName : 'fileList_ebook',
				hiddenName: 'field_ebook',
				hiddenValType:2,
				fileSingleSizeLimit:50*1024*1024,
				closeX:true
			},
			{
				fileType: 'service',
				filename : 'images',
			});
		});	
		$modal.modal({backdrop: 'static', keyboard: false});
	});
	$("#createreferral").on('click',function(){
		var data = $('.modelform').serializeJson();
		if ( data['book_id'] == undefined) {
			// updateAlert("书名不能为空", 'danger');
			// return false;
		}

		if (data['content'].length==0 && $("#field_ebook").val() == '') {
			updateAlert("内容不能为空", 'danger');
			return false;
		}
		var url = "{:url('add')}";
		$.ajax({
			type: "POST",
			url: url,
			data:data,
			dataType: "json",
			success: function(data){
				if(data.code==1){
					updateAlert(data.msg, 'success');
					setTimeout(function() {	
						window.location.reload();
					}, 100);
				}else{
					updateAlert("添加，"+data.msg, 'danger');
				}
			},
			error : function(e){
				console.log(e.status);
				console.log(e.responseText);
			}
		})
	});
});
</script>
{include file="material/pub_footer"}
{/block}